home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / ooo / f_0020 / sbasic.jar / text / sbasic / common / 01020100.xml < prev    next >
Encoding:
Extensible Markup Language  |  2003-08-01  |  27.2 KB  |  230 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <html><head><title>Using Variables</title><meta name="filename" content="text/sbasic/common/01020100"/><help:css-file-link xmlns:help="http://openoffice.org/2000/help"/><!--The CSS style header method for setting styles--><style type="text/css">
  3.  
  4.         table.Tabelle3{
  5.                 }
  6.         span.Tabelle3A{
  7.                 width:4.5cm;}
  8.         span.Tabelle3B{
  9.                 width:13.499cm;}
  10.         td.Tabelle3A1{
  11.                 }
  12.         td.Tabelle3B1{
  13.                 }
  14.         td.Tabelle3A2{
  15.                 }
  16.         td.Tabelle3B2{
  17.                 }
  18.         table.Tabelle4{
  19.                 }
  20.         span.Tabelle4A{
  21.                 width:4.339cm;}
  22.         span.Tabelle4B{
  23.                 width:13.66cm;}
  24.         td.Tabelle4A1{
  25.                 }
  26.         td.Tabelle4B1{
  27.                 }
  28.         td.Tabelle4A2{
  29.                 }
  30.         td.Tabelle4B2{
  31.                 }
  32.         table.Tabelle5{
  33.                 }
  34.         span.Tabelle5A{
  35.                 width:5.5cm;}
  36.         span.Tabelle5B{
  37.                 width:12.499cm;}
  38.         td.Tabelle5A1{
  39.                 }
  40.         table.Tabelle1{
  41.                 }
  42.         span.Tabelle1A{
  43.                 width:1.499cm;}
  44.         span.Tabelle1B{
  45.                 width:16.501cm;}
  46.         tr.Tabelle11{
  47.                 }
  48.         td.Tabelle1A1{
  49.                 }
  50.         table.Tabelle6{
  51.                 }
  52.         span.Tabelle6A{
  53.                 width:6.276cm;}
  54.         span.Tabelle6B{
  55.                 width:11.723cm;}
  56.         td.Tabelle6A1{
  57.                 }
  58.         td.Tabelle6B1{
  59.                 }
  60.         td.Tabelle6A2{
  61.                 }
  62.         td.Tabelle6B2{
  63.                 }
  64.         p.P1{
  65.                 }
  66.         p.P2{
  67.                 }
  68.         p.P3{
  69.                 }
  70.         span.T1{
  71.                 font-style:italic;}
  72.         span.T2{
  73.                 font-weight:bold;}
  74.         span.fr1{
  75.                 }
  76.         </style></head><body>
  77.   
  78.   
  79.   <help:paragraphinfo state="E" xmlns:help="http://openoffice.org/2000/help"/><help:to-be-embedded Eid="variable" xmlns:help="http://openoffice.org/2000/help">
  80.   <p class="Head1"><help:paragraphinfo state="U" number="1"/><help:key-word value="names of variables" tag="kw66464_1"/><help:key-word value="variables; types and names" tag="kw66464_3"/><help:link Id="66464">Using Variables</help:link></p>
  81.   <p class="Paragraph"><help:paragraphinfo state="U" number="3"/>The following describes the basic use of variables in <help:productname>%PRODUCTNAME</help:productname> Basic.</p>
  82.   <help:paragraphinfo state="E"/></help:to-be-embedded>
  83.   <p class="Head2"><help:paragraphinfo state="U" number="4" xmlns:help="http://openoffice.org/2000/help"/>Naming Conventions for Variable Identifiers</p>
  84.   <p class="Paragraph"><help:paragraphinfo state="U" number="5" xmlns:help="http://openoffice.org/2000/help"/>A variable name can consist of a maximum of 255 characters. The first character of a variable name <span class="T1">must</span> be a letter A-Z or a-z. Numbers can also be used in a variable name, but punctuation symbols and special characters are not permitted, with exception of the underscore character ("_"). In <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic variable identifiers are not case-sensitive. Variable names may contain spaces but must be enclosed in square brackets if they do.</p>
  85.   <p class="P2"><help:paragraphinfo state="U" number="6" xmlns:help="http://openoffice.org/2000/help"/>Examples for variable identifiers:</p>
  86.   <table border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" page-break-inside="page-break-inside:avoid"><tr class=""><th class="Tabelle3A1" style="text-align:left;"><span class="Tabelle3A">
  87.       <p class="PropText"><help:paragraphinfo state="U" number="7" xmlns:help="http://openoffice.org/2000/help"/>MyNumber=5</p>
  88.      </span></th><th class="Tabelle3B1" style="text-align:left;"><span class="Tabelle3B">
  89.       <p class="TextInTable"><help:paragraphinfo state="U" number="126" xmlns:help="http://openoffice.org/2000/help"/>Correct</p>
  90.      </span></th></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  91.      <p class="PropText"><help:paragraphinfo state="U" number="8" xmlns:help="http://openoffice.org/2000/help"/>MyNumber5=15</p>
  92.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  93.      <p class="TextInTable"><help:paragraphinfo state="U" number="127" xmlns:help="http://openoffice.org/2000/help"/>Correct</p>
  94.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  95.      <p class="PropText"><help:paragraphinfo state="U" number="9" xmlns:help="http://openoffice.org/2000/help"/>MyNumber_5=20</p>
  96.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  97.      <p class="TextInTable"><help:paragraphinfo state="U" number="128" xmlns:help="http://openoffice.org/2000/help"/>Correct</p>
  98.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  99.      <p class="PropText"><help:paragraphinfo state="U" number="10" xmlns:help="http://openoffice.org/2000/help"/>My Number=20</p>
  100.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  101.      <p class="TextInTable"><help:paragraphinfo state="U" number="11" xmlns:help="http://openoffice.org/2000/help"/>Not valid, variable with space must be enclosed in square brackets</p>
  102.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  103.      <p class="PropText"><help:paragraphinfo state="U" number="14" xmlns:help="http://openoffice.org/2000/help"/>[My Number]=12</p>
  104.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  105.      <p class="TextInTable"><help:paragraphinfo state="U" number="15" xmlns:help="http://openoffice.org/2000/help"/>Correct</p>
  106.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  107.      <p class="PropText"><help:paragraphinfo state="U" number="12" xmlns:help="http://openoffice.org/2000/help"/>D├⌐j├áVu=25</p>
  108.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  109.      <p class="TextInTable"><help:paragraphinfo state="U" number="129" xmlns:help="http://openoffice.org/2000/help"/>Not valid, special characters are not allowed</p>
  110.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  111.      <p class="PropText"><help:paragraphinfo state="U" number="13" xmlns:help="http://openoffice.org/2000/help"/>5MyNumber=12</p>
  112.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  113.      <p class="TextInTable"><help:paragraphinfo state="U" number="130" xmlns:help="http://openoffice.org/2000/help"/>Not valid, variable may not begin with a number</p>
  114.     </span></td></tr><tr class=""><td class="Tabelle3A2" style="text-align:left;"><span class="Tabelle3A">
  115.      <p class="PropText"><help:paragraphinfo state="U" number="16" xmlns:help="http://openoffice.org/2000/help"/>Number,Mine=12</p>
  116.     </span></td><td class="Tabelle3B2" style="text-align:left;"><span class="Tabelle3B">
  117.      <p class="TextInTable"><help:paragraphinfo state="U" number="131" xmlns:help="http://openoffice.org/2000/help"/>Not valid, punctuation marks are not allowed</p>
  118.     </span></td></tr></table>
  119.   <p class="Head2"><help:paragraphinfo state="U" number="17" xmlns:help="http://openoffice.org/2000/help"/>Declaring Variables</p>
  120.   <p class="Paragraph"><help:paragraphinfo state="U" number="18" xmlns:help="http://openoffice.org/2000/help"/>In <help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic you don't need to declare variables explicitly. An variable declaration can be performed with the <span class="T2">Dim</span> statement. You can declare more than one variable at a time by separating the names with a comma. To define the variable type, use either a type-declaration sign after the name, or the appropriate key word. </p>
  121.   <p class="P2"><help:paragraphinfo state="U" number="140" xmlns:help="http://openoffice.org/2000/help"/>Examples for variable declarations:</p>
  122.   <table border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" page-break-inside="page-break-inside:avoid"><tr class=""><th class="Tabelle4A1" style="text-align:left;"><span class="Tabelle4A">
  123.       <p class="PropText"><help:paragraphinfo state="U" number="19" xmlns:help="http://openoffice.org/2000/help"/>DIM a$</p>
  124.      </span></th><th class="Tabelle4B1" style="text-align:left;"><span class="Tabelle4B">
  125.       <p class="TextInTable"><help:paragraphinfo state="U" number="132" xmlns:help="http://openoffice.org/2000/help"/>Declares the variable "a" as a String</p>
  126.      </span></th></tr><tr class=""><td class="Tabelle4A2" style="text-align:left;"><span class="Tabelle4A">
  127.      <p class="PropText"><help:paragraphinfo state="U" number="20" xmlns:help="http://openoffice.org/2000/help"/>DIM a As String</p>
  128.     </span></td><td class="Tabelle4B2" style="text-align:left;"><span class="Tabelle4B">
  129.      <p class="TextInTable"><help:paragraphinfo state="U" number="133" xmlns:help="http://openoffice.org/2000/help"/>Declares the variable "a" as a String</p>
  130.     </span></td></tr><tr class=""><td class="Tabelle4A2" style="text-align:left;"><span class="Tabelle4A">
  131.      <p class="PropText"><help:paragraphinfo state="U" number="21" xmlns:help="http://openoffice.org/2000/help"/>DIM a$, b As Integer</p>
  132.     </span></td><td class="Tabelle4B2" style="text-align:left;"><span class="Tabelle4B">
  133.      <p class="TextInTable"><help:paragraphinfo state="U" number="22" xmlns:help="http://openoffice.org/2000/help"/>Declares one variable as a String and one as an Integer</p>
  134.     </span></td></tr></table>
  135.   <p class="Paragraph"><help:paragraphinfo state="U" number="23" xmlns:help="http://openoffice.org/2000/help"/>It is very important when declaring variables that you use the type-declaration character each time, even if it was used in the declaration instead of a keyword. Thus the following statements are invalid:</p>
  136.   <table><tr class=""><th class="Tabelle5A1" style="text-align:left;"><span class="Tabelle5A">
  137.       <p class="PropText"><help:paragraphinfo state="U" number="24" xmlns:help="http://openoffice.org/2000/help"/>DIM a$</p>
  138.      </span></th><th class="Tabelle5A1" style="text-align:left;"><span class="Tabelle5B">
  139.       <p class="Paragraph"><help:paragraphinfo state="U" number="134" xmlns:help="http://openoffice.org/2000/help"/>Declares "a" as a String</p>
  140.      </span></th></tr><tr class=""><td class="Tabelle5A1" style="text-align:left;"><span class="Tabelle5A">
  141.      <p class="PropText"><help:paragraphinfo state="U" number="25" xmlns:help="http://openoffice.org/2000/help"/>a="TestString"</p>
  142.     </span></td><td class="Tabelle5A1" style="text-align:left;"><span class="Tabelle5B">
  143.      <p class="Paragraph"><help:paragraphinfo state="U" number="135" xmlns:help="http://openoffice.org/2000/help"/>Type-declaration missing: "a$="</p>
  144.     </span></td></tr></table>
  145.   <table><tr class="Tabelle11"><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1A">
  146.       <p class="TextInTable"><draw:image draw:name="Icon0" svg:desc="Warning Icon" svg:pixelx="32" svg:pixely="32" svg:width="0.847cm" svg:height="0.847cm" xlink:href="65640" draw:filter-name="" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"/></p>
  147.  
  148.      </span></th><th class="Tabelle1A1" style="text-align:left;"><span class="Tabelle1B">
  149.       <p class="TextInTable"><help:paragraphinfo state="U" number="26" xmlns:help="http://openoffice.org/2000/help"/>Once you have declared a variable as a certain type, you cannot declare the variable under the same name again as a different type!</p>
  150.      </span></th></tr></table>
  151.   <p class="Head3"><help:paragraphinfo state="U" number="27" xmlns:help="http://openoffice.org/2000/help"/>Forcing Variable Declarations</p>
  152.   <p class="Paragraph"><help:paragraphinfo state="U" number="28" xmlns:help="http://openoffice.org/2000/help"/>To force declaration of variables, use the following command:</p>
  153.   <p class="PropText"><help:paragraphinfo state="U" number="29" xmlns:help="http://openoffice.org/2000/help"/>OPTION EXPLICIT</p>
  154.   <p class="Paragraph"><help:paragraphinfo state="U" number="30" xmlns:help="http://openoffice.org/2000/help"/>The <span class="T2">Option Explicit</span> statement has to be the first line in the module, before the first SUB. Generally, only arrays need to be declared explicitly. All other variables are declared according to the type-declaration character, or - if omitted - as the default type <span class="T2">Single</span>.</p>
  155.   <p class="Head2"><help:paragraphinfo state="U" number="34" xmlns:help="http://openoffice.org/2000/help"/><help:key-word value="types of variables" tag="kw66464_2" xmlns:help="http://openoffice.org/2000/help"/>Variable Types</p>
  156.   <p class="Paragraph"><help:paragraphinfo state="U" number="35" xmlns:help="http://openoffice.org/2000/help"/><help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic supports four variable classes:</p>
  157.   <ul class="L1">
  158.    <li class="">
  159.     <p class="P3"><help:paragraphinfo state="U" number="36" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">Numeric</span> variables can contain number values. Some variables are used to store large or small numbers, and others are used for floating-point or fractional numbers. </p>
  160.    </li>
  161.    <li class="">
  162.     <p class="P3"><help:paragraphinfo state="U" number="37" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">String</span> variables contain character strings.</p>
  163.    </li>
  164.    <li class="">
  165.     <p class="P3"><help:paragraphinfo state="U" number="38" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">Boolean</span> variables contain either the TRUE or the FALSE value.</p>
  166.    </li>
  167.    <li class="">
  168.     <p class="P3"><help:paragraphinfo state="U" number="39" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">Object</span> variables can store objects of various types, like tables and documents within a document.</p>
  169.    </li>
  170.   </ul>
  171.   <p class="Head3"><help:paragraphinfo state="U" number="40" xmlns:help="http://openoffice.org/2000/help"/>Integer Variables</p>
  172.   <p class="Paragraph"><help:paragraphinfo state="U" number="41" xmlns:help="http://openoffice.org/2000/help"/>Integer variables range from -32768 to 32767. If you assign a floating-point value to an integer variable, the decimal places are rounded to the next integer. Integer variables are rapidly calculated in procedures and are suitable for counter variables in loops. An integer variable only requires two bytes of memory. "%" is the type-declaration character.</p>
  173.   <p class="PropText"><help:paragraphinfo state="U" number="43" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable%</p>
  174.   <p class="PropText"><help:paragraphinfo state="U" number="44" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As Integer</p>
  175.   <p class="Head3"><help:paragraphinfo state="U" number="45" xmlns:help="http://openoffice.org/2000/help"/>Long Integer Variables</p>
  176.   <p class="Paragraph"><help:paragraphinfo state="U" number="46" xmlns:help="http://openoffice.org/2000/help"/>Long integer variables range from -2147483648 to 2147483647. If you assign a floating-point value to a long integer variable, the decimal places are rounded to the next integer. Long integer variables are rapidly calculated in procedures and are suitable for counter variables in loops for large values. A long integer variable requires four bytes of memory. "&" is the type-declaration character.</p>
  177.   <p class="PropText"><help:paragraphinfo state="U" number="48" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable&</p>
  178.   <p class="PropText"><help:paragraphinfo state="U" number="49" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable as Long</p>
  179.   <p class="Head3"><help:paragraphinfo state="U" number="50" xmlns:help="http://openoffice.org/2000/help"/>Single Variables</p>
  180.   <p class="Paragraph"><help:paragraphinfo state="U" number="51" xmlns:help="http://openoffice.org/2000/help"/>Single variables can take positive or negative values ranging from 3.402823┬áx┬á10E38 to 1.401298┬áx┬á10E-45. Single variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Single variables are suitable for mathematical calculations of average precision. Calculations require more time than for Integer variables, but are faster than calculations with Double variables. A Single variable requires 4 bytes of memory. The type-declaration character is <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>"!".</p>
  181.   <p class="PropText"><help:paragraphinfo state="U" number="52" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable!</p>
  182.   <p class="PropText"><help:paragraphinfo state="U" number="53" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable as Single</p>
  183.   <p class="Head3"><help:paragraphinfo state="U" number="54" xmlns:help="http://openoffice.org/2000/help"/>Double Variables</p>
  184.   <p class="Paragraph"><help:paragraphinfo state="U" number="55" xmlns:help="http://openoffice.org/2000/help"/>Double variables can take positive or negative values ranging from 1.79769313486232┬áx┬á10E308 to 4.94065645841247┬áx┬á10E-324. Double variables are floating-point variables, in which the decimal precision decreases as the non-decimal part of the number increases. Double variables are suitable for precise calculations. Calculations require more time than for Single variables. A Double variable requires 8 bytes of memory. The type-declaration character is <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>"#".</p>
  185.   <p class="PropText"><help:paragraphinfo state="U" number="56" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable#</p>
  186.   <p class="PropText"><help:paragraphinfo state="U" number="57" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As Double</p>
  187.   <p class="Head3"><help:paragraphinfo state="U" number="95" xmlns:help="http://openoffice.org/2000/help"/>Currency Variables</p>
  188.   <p class="Paragraph"><help:paragraphinfo state="U" number="96" xmlns:help="http://openoffice.org/2000/help"/>Currency variables are internally stored as 64-bit numbers (8 Bytes) and displayed as a fixed-decimal number with 15 non-decimal and 4 decimal places. The values range from -922337203685477.5808 to +922337203685477.5807. Currency variables are used to calculate currency values with a high precision. The <text:s text:c="" xmlns:text="http://openoffice.org/2000/text"/>type-declaration character is "@".</p>
  189.   <p class="PropText"><help:paragraphinfo state="U" number="97" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable@</p>
  190.   <p class="PropText"><help:paragraphinfo state="U" number="98" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As Currency</p>
  191.   <p class="Head3"><help:paragraphinfo state="U" number="58" xmlns:help="http://openoffice.org/2000/help"/>String Variables</p>
  192.   <p class="Paragraph"><help:paragraphinfo state="U" number="59" xmlns:help="http://openoffice.org/2000/help"/>String variables can hold character strings with up to 65,535 characters. Each character is stored as the corresponding Unicode value. String variables are suitable for word processing within programs and for temporary storage of any non-printable character up to a maximum length of 64 Kbytes. The memory required for storing string variables depends on the number of characters in the variable. The type-declaration character is "$".</p>
  193.   <p class="PropText"><help:paragraphinfo state="U" number="60" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable$</p>
  194.   <p class="PropText"><help:paragraphinfo state="U" number="61" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As String</p>
  195.   <p class="Head3"><help:paragraphinfo state="U" number="62" xmlns:help="http://openoffice.org/2000/help"/>Boolean Variables</p>
  196.   <p class="Paragraph"><help:paragraphinfo state="U" number="63" xmlns:help="http://openoffice.org/2000/help"/>Boolean variables store only one of two values: TRUE or FALSE. Boolean variables are used to store binary values, like the result of a comparison and are represented internally by a 2-byte integer value. Any value assigned to a Boolean is converted to "False" if the value is not exactly equal to "-1". Boolean variables can only be declared by the key words True or False.</p>
  197.   <p class="PropText"><help:paragraphinfo state="U" number="64" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As Boolean</p>
  198.   <p class="Head3"><help:paragraphinfo state="U" number="65" xmlns:help="http://openoffice.org/2000/help"/>Date Variables</p>
  199.   <p class="Paragraph"><help:paragraphinfo state="U" number="66" xmlns:help="http://openoffice.org/2000/help"/>Date variables can only contain dates and time values stored in an internal format. Values assigned to Date variables with <help:link Id="66424" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Dateserial</span></help:link>, <help:link Id="66574" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Datevalue</span></help:link>, <help:link Id="66520" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Timeserial</span></help:link> or <help:link Id="66550" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Timevalue</span></help:link> are automatically converted to the internal format. Date-variables are converted to normal numbers by using the <help:link Id="66388" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Day</span></help:link>, <help:link Id="66585" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Month</span></help:link>, <help:link Id="66537" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Year</span></help:link> or the <help:link Id="66572" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Hour</span></help:link>, <help:link Id="66487" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Minute</span></help:link>, <help:link Id="66629" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Second</span></help:link> function. The internal format enables a comparison of date/time values by calculating the difference between two numbers. These variables can only be declared with the key word <span class="T2">Date</span>.</p>
  200.   <p class="PropText"><help:paragraphinfo state="U" number="67" xmlns:help="http://openoffice.org/2000/help"/>Dim Variable As Date</p>
  201.   <p class="Head2"><help:paragraphinfo state="U" number="68" xmlns:help="http://openoffice.org/2000/help"/>Initial Variable Values</p>
  202.   <p class="Paragraph"><help:paragraphinfo state="U" number="69" xmlns:help="http://openoffice.org/2000/help"/>As soon as the variable has been declared, it is automatically set to the "Null" value. Note the following conventions:</p>
  203.   <p class="Paragraph"><help:paragraphinfo state="U" number="70" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">Numeric</span> variables are automatically assigned the value "0" as soon as they are declared.</p>
  204.   <p class="Paragraph"><help:paragraphinfo state="U" number="71" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">Date variables</span> are assigned the value 0 internally; equivalent to converting the value to "0" with the <help:link Id="66388" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Day</span></help:link>, <help:link Id="66585" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Month</span></help:link>, <help:link Id="66537" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Year</span></help:link> or the <help:link Id="66572" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Hour</span></help:link>, <help:link Id="66487" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Minute</span></help:link>, <help:link Id="66629" xmlns:help="http://openoffice.org/2000/help"><span class="T2">Second</span></help:link> function.</p>
  205.   <p class="Paragraph"><help:paragraphinfo state="U" number="72" xmlns:help="http://openoffice.org/2000/help"/><span class="T2">String variables</span> are assigned an empty-string ("") when they are declared.</p>
  206.   <p class="Head2"><help:paragraphinfo state="U" number="83" xmlns:help="http://openoffice.org/2000/help"/>Arrays</p>
  207.   <p class="Paragraph"><help:paragraphinfo state="U" number="84" xmlns:help="http://openoffice.org/2000/help"/><help:productname xmlns:help="http://openoffice.org/2000/help">%PRODUCTNAME</help:productname> Basic knows one- or multi-dimensional arrays, defined by a specified variable type. Arrays are suitable for editing lists and tables in programs. Individual elements of an array can be addressed through a numeric index.</p>
  208.   <p class="Paragraph"><help:paragraphinfo state="U" number="85" xmlns:help="http://openoffice.org/2000/help"/>Arrays <span class="T1">must</span> be declared with the <span class="T2">Dim</span> statement. There are several ways to define the index range of an array:</p>
  209.   <table border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" page-break-inside="page-break-inside:avoid"><tr class=""><th class="Tabelle6A1" style="text-align:left;"><span class="Tabelle6A">
  210.       <p class="PropText"><help:paragraphinfo state="U" number="86" xmlns:help="http://openoffice.org/2000/help"/>DIM text$(20)</p>
  211.      </span></th><th class="Tabelle6B1" style="text-align:left;"><span class="Tabelle6B">
  212.       <p class="TableHead"><help:paragraphinfo state="U" number="136" xmlns:help="http://openoffice.org/2000/help"/>21 elements numbered from 0 to 20</p>
  213.      </span></th></tr><tr class=""><td class="Tabelle6A2" style="text-align:left;"><span class="Tabelle6A">
  214.      <p class="PropText"><help:paragraphinfo state="U" number="125" xmlns:help="http://openoffice.org/2000/help"/>DIM text$(5,4)</p>
  215.     </span></td><td class="Tabelle6B2" style="text-align:left;"><span class="Tabelle6B">
  216.      <p class="TextInTable"><help:paragraphinfo state="U" number="137" xmlns:help="http://openoffice.org/2000/help"/>30 elements (a matrix of 6 x 5 elements)</p>
  217.     </span></td></tr><tr class=""><td class="Tabelle6A2" style="text-align:left;"><span class="Tabelle6A">
  218.      <p class="PropText"><help:paragraphinfo state="U" number="87" xmlns:help="http://openoffice.org/2000/help"/>DIM text$(5 to 25)</p>
  219.     </span></td><td class="Tabelle6B2" style="text-align:left;"><span class="Tabelle6B">
  220.      <p class="TextInTable"><help:paragraphinfo state="U" number="138" xmlns:help="http://openoffice.org/2000/help"/>21 elements numbered from 5 to 25</p>
  221.     </span></td></tr><tr class=""><td class="Tabelle6A2" style="text-align:left;"><span class="Tabelle6A">
  222.      <p class="PropText"><help:paragraphinfo state="U" number="88" xmlns:help="http://openoffice.org/2000/help"/>DIM text$(-15 to 5)</p>
  223.     </span></td><td class="Tabelle6B2" style="text-align:left;"><span class="Tabelle6B">
  224.      <p class="TextInTable"><help:paragraphinfo state="U" number="89" xmlns:help="http://openoffice.org/2000/help"/>21 elements (including 0), numbered from -15 to 5</p>
  225.     </span></td></tr></table>
  226.   <p class="Paragraph"><help:paragraphinfo state="U" number="90" xmlns:help="http://openoffice.org/2000/help"/>The index range can include positive as well as negative numbers. The maximum number of elements that can be addressed through an index is 16368.</p>
  227.   <p class="Head2"><help:paragraphinfo state="U" number="91" xmlns:help="http://openoffice.org/2000/help"/>Constants</p>
  228.   <p class="Paragraph"><help:paragraphinfo state="U" number="92" xmlns:help="http://openoffice.org/2000/help"/>Constants have a fixed value. They are only defined once in the program and cannot be redefined later:</p>
  229.   <p class="PropText"><help:paragraphinfo state="U" number="93" xmlns:help="http://openoffice.org/2000/help"/>CONST ConstName=Expression</p>
  230.  </body></html>